// components/imagePreviewer/imagePreviewer.js
import config from '../../config'
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    urls: {
      type: Array,
      default: []
    }
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    previewImage(e) {
      e = e.currentTarget.dataset
      const arr = (() => {
        let re = JSON.parse(JSON.stringify(this.properties.urls))
        for (let i = 0; i < re.length; i++) {
          re[i] = config.imagePrefix + re[i]
        }
        return re
      })()
      console.log(arr)
      wx.previewImage({
        urls: arr,
        current: arr[e.index || 0]
      })
    }
  }
})